#/*
# * Copyright {c} 2020-2021, SERI Development Team
# *
# * SPDX-License-Identifier: Apache-2.0
# *
# * Change Logs:
# * Date         Author          Notes
# * 2022-04-04   Lyons           first version
# */

COLORS = "\033[32m"
COLORE = "\033[0m"

.PHONY: help
help:
	@echo "help     - help menu             "
	@echo "build    - compile c/asm file    "

.PHONY: build
build:
	@echo -e ${COLORS}[INFO] compile c/asm file ...${COLORE}
	${Q}${CC} ${INCLUDES} ${INCFILES} ${CFLAGS} ${LDFLAGS} ${LDLIBS} ${ASMFILES} ${CFILES} -o ${TARGET}.elf
	@echo -e ${COLORS}[INFO] create dump file ...${COLORE}
	${Q}${OBJDUMP} -D -S ${TARGET}.elf > ${TARGET}.dump
	@echo -e ${COLORS}[INFO] create image file ...${COLORE}
	${Q}${OBJCOPY} -S -O binary  ${TARGET}.elf ${TARGET}.bin
	${Q}${CP} ${TARGET}.bin ${PROJPATH}/../${TARGET}.bin
	@echo -e ${COLORS}[INFO] execute done${COLORE}

.PHONY: clean
clean:
	@echo -e ${COLORS}[INFO] clean project ...${COLORE}
	@ls | grep -vE "Makefile|*\.lds$$|*\.c$$|*\.h$$" | xargs -i rm -rf {}
	@echo -e ${COLORS}[INFO] execute done${COLORE}